package Homework;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.Map.Entry;

public class work06 {

	public static void main(String[] args) {
		int[] a={1,2,3,4,5,8};
		int[] b={5,7,3,4,9};
		distinct(a,b);
	}

	private static void distinct(int[] a, int[] b) {
		HashMap<Integer,Integer> hashMap = new HashMap();
		ArrayList<Integer> newArr = new ArrayList<Integer>();
		for(int i : a){
			if(hashMap.containsKey(i)){
				int value = hashMap.get(i);
				hashMap.put(i, value+1);
			}else{
				hashMap.put(i, 1);
			}
		}
		for(int i : b){
			if(hashMap.containsKey(i)){
				int value = hashMap.get(i);
				hashMap.put(i, value+1);
			}else{
				hashMap.put(i, 1);
			}
		}
		Set<Entry<Integer, Integer>> entrySet = hashMap.entrySet();
		for(Entry<Integer, Integer> e : entrySet){
			if(e.getValue()==1){
				newArr.add(e.getKey());
			}
		}
		System.out.println(newArr);
	}

	
}
